package com.ms.banner.transformer;

import com.ms.banner.util.NumberUtil;
import ohos.agp.components.Component;

public class BackgroundToForegroundTransformer extends ABaseTransformer {

    @Override
    public void onTransform(Component component, float position) {
        float height = (float) component.getHeight();
        float width = (float) component.getWidth();
        float scale = min(position < (float) 0 ? 1.0F : Math.abs(NumberUtil.sub(1.0F, position)), 0.5F);
        component.setScaleX(scale);
        component.setScaleY(scale);
        component.setPivotX(NumberUtil.mul(width, 0.5F));
        component.setPivotY(NumberUtil.mul(height, 0.5F));
        component.setTranslationX(position < (float) 0 ? NumberUtil.mul(width, position) : NumberUtil.mul(NumberUtil.mul(-width, position), 0.25F));
    }

}
